<html lang="en"><head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Connect Web Server</title>


    <!-- Framework CSS -->
    
    <link rel="stylesheet" href="css/blueprint/screen.css" type="text/css" media="screen, projection">
    <link rel="stylesheet" href="css/blueprint/print.css" type="text/css" media="print">
    <!--[if lt IE 8]><link rel="stylesheet" href="css/blueprint/ie.css" type="text/css" media="screen, projection"><![endif]-->

    <!-- Import fancy-type plugin for the sample page. -->
    <link rel="stylesheet" href="css/blueprint/fancytype.css" type="text/css" media="screen, projection">
    
    <!-- Custom styles to override framework -->
     <link rel="stylesheet" href="css/main.css" type="text/css" media="screen, projection">
  </head>
<body>
    <div class="container">
   
    
      <br/>
      <h1><a href="/"><img src="images/ConnectLogo.png"  alt="Connect" style="vertical-align:middle;" ></a>  Connect Web Server Reference</h1>
      
      <hr>
      <h2 class="alt"><a href="/">Home</a> | <a href="scriptingRef.html">Scripting</a> | <a href="freemarkerExtensions.html">Freemarker Extensions</a> | Server Configuration</h2>
      <hr>
     
      <hr class="space">
      <div class="span-20 prepend-1">
       <h3>Basics</h3>
       <p> On startup, Connect looks for the server configuration file to configure where it will look for scripts, pages and static content. The URL mappings to access pages and scripts are loaded from here as well. The server configuration is found in the <b>etc/serverconfig.xml</b> file. This consists of the following sections:</p>
          
          <ul>
          <li>Server</li>
              <li>SessionManager</li>
              <li>Authenticator</li>
              <li>Pages</li>
               <li>Scripts</li>
          </ul>
          
          
          <h4>Server</h4>
          <p> The server tag has a number of attributes to configure the general behaviour of Connect.</p>
          <br>
           <p class="code">
&lt;server name="Webserver" port="8080" serverRoot="www/root" pageBase="www/pages" scriptBase="www/scripts"  loginURL="static/login.html"&gt;
            </p>
          <br/>
        <p><b>name</b> - Name to identify the server.<br/>
        <b>port</b> - HTTP port the server is accessed on.<br/>
        <b>serverRoot</b> - Root folder of the web server.<br/>
        <b>pageBase</b> - Folder holding the pages.<br/>
        <b>scriptBase</b> - Folder holding the scrips.<br/>
        <b>loginURL</b> - URL of the page to challenge the user with for authentication.</p>
          
          <h4>SessionManager</h4>
          <p> Connect uses a pluggable session manager framework, with the default using a Cookie based session management approach. The inner tags of this item are made available to your class as a name/value property mapping for configuring your code. </p>
          <br>
           <p class="code">
&lt;sessionManager class=&quot;com.binarycube.webserver.session.CookieSessionManager&quot; &gt;<br>
&lt;cookieName&gt;sessionCookie&lt;/cookieName&gt;<br>
&lt;/sessionManager&gt;
            </p>
          <br/>
        <p><b>class</b> - Class which performs the session management..<br/>
        <b>cookieName</b> - The name of the cookie in which the session info is stored.<br/>
      </p>
          
          
          <h4>Authenticator</h4>
          <p> Continuing the pluggable theme, Connect allows you to configure your own Authenticator to validate logins. There are a couple of commented out options in the default configuration file that you can experiment with. We will look at the <b>LDAPAuthenticator</b> here. </p><p>The authenticator main tag is constant for all authenticator implementations, defining which HTTP Request fields are used for the user credentials, to then perform the authentication with.
          </p>
          <br>
           <p class="code">
&lt;authenticator class=&quot;com.binarycube.webserver.authenticator.LDAPAuthenticator&quot; usernameField=&quot;name&quot; passwordField=&quot;password&quot;&gt;<br>
	&lt;host&gt;localhost&lt;/host&gt;<br>
	&lt;port&gt;389&lt;/port&gt;<br>
	&lt;base&gt;ou=users,dc=binarycube,dc=com&lt;/base&gt;<br>
&lt;/authenticator&gt;
            </p>
          <br/>
        <p><b>host</b> - LDAP server URL.<br/>
        <b>port</b> - LDAP port the server is accessed on.<br/>
        <b>base</b> - The DN of the container in which the users are found on the LDAP server.<br/>
       </p>
          
          
          <h4>Page</h4>
          <p> Pages are the dynamically generated, Freemarker based, templated HTML pages server by Connect. </p>
          <br>
           <p class="code">
&lt;page name=&quot;helloWorld&quot; src=&quot;hello.ftl&quot; visibility=&quot;public&quot;/&gt;
            </p>
          <br/>
        <p><b>name</b> - URL the page is access on. eg. http://myserver/pages/[page name]<br/>
        <b>src</b> - Location within the server pageBase of the template file.<br/>
        <b>visibility</b> - Whether the page is accessible by unauthorised users.<br/></p>
      
          
          
          <h4>Script</h4>
          <p> Scripts are configured in a similar fashion to pages in Connect. Simply define the source file, URL mapping and visibility.</p>
          <br>
           <p class="code">
&lt;page name=&quot;helloWorld&quot; src=&quot;hello.ftl&quot; visibility=&quot;public&quot;/&gt;
            </p>
          <br/>
        <p><b>name</b> - URL the page is access on. eg. http://myserver/pages/[page name]<br/>
        <b>src</b> - Location within the server pageBase of the template file.<br/>
        <b>visibility</b> - Whether the page is accessible by unauthorised users.<br/></p>
          
		<hr>
       
         <h3>DataSources</h3>
       <p> DataSources in Connect are configured through the <b>etc/data.xml</b> file. Once configured, the named datasource is available to scripts and pages in Connect. All datasources follow the configuration structure below, with the name, implementing class, and parameter and configuration sections. Refer to the javadoc for more detail on the implementation of datasources, and for examples, refer to the default data.xml that shows all of the various data sources available through Connect. </p>
          <pre  class="code">

&lt;datasource name=&quot;FolderDataSource&quot; class=&quot;com.binarycube.webserver.datasource.FolderDataSource&quot;&gt;
	&lt;!--  Parameters are passed to the datasource when you query it --&gt;
	&lt;parameters&gt;
		&lt;parameter name=&quot;path&quot; default=&quot;.&quot; /&gt;
	&lt;/parameters&gt;
	&lt;!--  The config section sets up the datasource ready to access --&gt;
	&lt;config&gt;
		&lt;folder&gt;www&lt;/folder&gt;
	&lt;/config&gt;
&lt;/datasource&gt;
  
    </pre>
        
		
        
        
      </div>
      <hr/>
      <div class="last quiet right"> 
          <a href="http://www.binarycube.com"><img src="images/logo-bw.png" width="150" /></a><br/>
      </div>
</div>
  

</body></html>